﻿using Pb;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PDKCardsControl : MonoBehaviour {

    EginUser user = EginUser.Instance;
    EginPDK pdk = EginPDK.Instance;
    public GameObject ownCardsObj;
    public List<UISprite> ownCards;
    public GameObject LeftCard;
    //public List<UISprite> LeftRemainderCards;
    public GameObject rightCard;
    //public List<UISprite> rightRemainderCards;
    public List<int> ownCardsInControl;
    public UILabel LeftRemaindLabel;
    public UILabel RightRemainLabel;
    public List<GameObject> passStatusObjs;
    public int leftRemainder;
    public int rightRemainder;
    public int ownRemainder;

    //牌的控制
    public POKER_TYPE lastPokerType;
    public int lastSeatId;
    public List<int> lastOutCards = new List<int>();

    //出牌按钮
    public GameObject outCardBtnFather;
    public GameObject tiShiBtn;
    public GameObject outBtn;
    //取消托管
    public GameObject CancelAuto;
    public GameObject CancelAutaStatusBtn;

    //出出去的牌显示
    public GameObject PlayerOutCardFather;
    public PDKPlayerOutCards pdkPlayerOutCards;
    public UISprite OutCardType;

    private PDKGame pdkGame;

	void Awake () {
        UIEventListener.Get(tiShiBtn).onClick = ButtonClick;
        UIEventListener.Get(outBtn).onClick = ButtonClick;
        UIEventListener.Get(CancelAutaStatusBtn).onClick = ButtonClick;
        pdkGame = GameObject.Find("UI Root/Camera").GetComponent<PDKGame>();
	}

    void Start()
    {
        
    }

    void ButtonClick(GameObject button)
    {
        if (button.name == "PromptGreenBtn")
        {
            //提示
            Debug.Log("点击提示按钮");
            PromptEvent();
        }
        else if (button.name == "OutCardOrangeBtn")
        {
            //出牌
            Debug.Log("点击出牌按钮");
            OutCardEvent();
            //将button的碰撞取消
            outBtn.GetComponent<UIButton>().enabled = false;
        }
        else if (button.name == "CancelAutoSatusBtn")
        {
            //发送取消托管请求
            UserCancelRobotRequest uc = new UserCancelRobotRequest { };
            SocketManager socketManager = SocketManager.Instance;
            socketManager.SendProtobuf1(uc,MsgId.UserCancelRobotRequest);
            Debug.Log("发送了取消托管请求");
        }
    }


    public void InitBtn()
    {
        PromptCount = 0;
        promptCards.Clear();//把提示出牌使用的字典索引 重置为0

        outCardBtnFather.SetActive(false);
        //outBtn.SetActive(false);
        //tiShiBtn.SetActive(false); 
                     
    }
 


    /// <summary>
    /// 发牌之后显示牌
    /// </summary>
    public void StartShowCards(List<int> cards)
    {
        //保存已经排好序的手牌列表
        ownCardsInControl = SortOwnCards(cards);
        StartCoroutine(ShowOwnCards());
        //其他玩家剩余牌显示
        leftRemainder = 16;
        rightRemainder = 16;
        ownRemainder = 16;
    }

    /// <summary>
    /// 跑得快重连显示牌
    /// </summary>
    /// <param name="ownCards"></param>
    public void ReconnectShowCards(List<int> ownCards)
    {        
        ownCards = SortOwnCards(ownCards);       
        ownCardsInControl = ownCards;
        RedisplayCards();
        
    }

    /// <summary>
    /// 移除玩家出的牌
    /// </summary>
    /// <param name="cards"></param>
    public void RemoveOutCards(List<int> cards)
    {
        if (cards.Count > 0)
        {
            for (int i = 0; i < cards.Count; i++)
            {
                ownCardsInControl.Remove(cards[i]);
            }
            RedisplayCards();
        }
    }


    /// <summary>
    /// 对自己的手牌进行排序 从大到小排列
    /// </summary>
    /// <param name="cards"></param>
    /// <returns></returns>
    List<int> SortOwnCards(List<int> cards)
    {
        List<int> temp = new List<int>();
        //List<int> temp1 = new List<int>();
        //先找出2 将2添加进临时列表中
        for (int i = 0; i < cards.Count;i++ )
        {
            if(cards[i] % 13 == 0){
                temp.Add(cards[i]);
                cards.RemoveAt(i);
            }
        }

        //将剩余的牌从大到小添加进临时列表中
        for (int i = 12; i > 0;i-- )
        {
            for (int j = 0; j < cards.Count;j++ )
            {
                if(cards[j] % 13 == i){
                    temp.Add(cards[j]);
                }
            }
        }
        return temp;
    }

    /// <summary>
    /// 开始展示自己的牌
    /// </summary>
    IEnumerator ShowOwnCards()
    {        
        for (int i = 0; i < ownCards.Count;i++ )
        {
            ownCards[i].gameObject.SetActive(false);
            ownCards[i].GetComponent<PDKCardButton>().Select = false;
            ownCards[i].gameObject.transform.localPosition = new Vector3(ownCards[i].transform.localPosition.x, 0, 0);
        }

        int j = 0;
        int tempInt = 16 - ownCardsInControl.Count;
        for (int i = 16 - ownCardsInControl.Count; i < ownCardsInControl.Count + tempInt; i++)
        {
            ownCards[i].gameObject.SetActive(true);
            ownCards[i].gameObject.name = ownCardsInControl[j].ToString();
            ownCards[i].spriteName = ownCardsInControl[j].ToString();
            ownCards[i].gameObject.GetComponent<UIButton>().normalSprite = ownCardsInControl[j].ToString();
            float x = 0 - (16 - ownCardsInControl.Count - 2) * (float)26.5;
            ownCardsObj.transform.localPosition = new Vector3(x, ownCardsObj.transform.localPosition.y, 0);
            yield return new WaitForSeconds(0.1f);
            j++;

        }
        float xx = 0 - (16 - ownCardsInControl.Count - 2) * (float)26.5;
        ownCardsObj.transform.localPosition = new Vector3(xx, ownCardsObj.transform.localPosition.y, 0);
    }

    /// <summary>
    /// 重新显示手牌
    /// </summary>
    public void RedisplayCards()
    {
        for (int i = 0; i < ownCards.Count; i++)
        {
            ownCards[i].gameObject.SetActive(false);
            ownCards[i].GetComponent<PDKCardButton>().Select = false;
            ownCards[i].gameObject.transform.localPosition = new Vector3(ownCards[i].transform.localPosition.x, 0, 0);
        }

        int j = 0;
        int tempInt = 16 - ownCardsInControl.Count;
        for (int i = tempInt; i < ownCardsInControl.Count + tempInt; i++)
        {
            ownCards[i].gameObject.SetActive(true);
            ownCards[i].gameObject.name = ownCardsInControl[j].ToString();
            ownCards[i].spriteName = ownCardsInControl[j].ToString();
            ownCards[i].gameObject.GetComponent<UIButton>().normalSprite = ownCardsInControl[j].ToString();
            //float x = 0 - (16 - ownCardsInControl.Count - 2) * (float)26.5;
            //ownCardsObj.transform.localPosition = new Vector3(x, ownCardsObj.transform.localPosition.y, 0);           
            j++;

        }
        float x = 0 - (16 - ownCardsInControl.Count - 2) * (float)26.5;
        ownCardsObj.transform.localPosition = new Vector3(x, ownCardsObj.transform.localPosition.y, 0);
    }

    /// <summary>
    /// 其他玩家剩余牌显示
    /// </summary>
    /// <param name="remainder"></param>
    /// <param name="otherSid"></param>
    public void OtherCardRemainderShow(int remainder, int otherSid)
    {
        if (pdk.seatId == 1)
        {
            if (otherSid == 3)
            {
                leftRemainder += remainder;
                LeftRemaindLabel.text = leftRemainder + "";
            }
            else if (otherSid == 2)
            {
                rightRemainder += remainder;
                RightRemainLabel.text = rightRemainder + "";
            }
            else if (otherSid == 1)
            {
                ownRemainder += remainder;                
            }

        }
        else if (pdk.seatId == 2)
        {
            if (otherSid == 1)
            {
                leftRemainder += remainder;
                LeftRemaindLabel.text = leftRemainder + "";
            }
            else if (otherSid == 3)
            {
                rightRemainder += remainder;
                RightRemainLabel.text = rightRemainder + "";
            }
            else if (otherSid == 2)
            {
                ownRemainder += remainder;
            }
        }
        else if (pdk.seatId == 3)
        {
            if (otherSid == 2)
            {
                leftRemainder += remainder;
                LeftRemaindLabel.text = leftRemainder + "";
            }
            else if (otherSid == 1)
            {
                rightRemainder += remainder;
                RightRemainLabel.text = rightRemainder + "";
            }
            else if (otherSid == 3)
            {
                ownRemainder += remainder;
            }
        }
    }



    /// <summary>
    /// 显示出牌 提示按钮
    /// </summary>
    public void ShowOutCardButton()
    {
        //判断上家是不是自己 是的话显示出牌 不是判断是否要的起->要的起显示出牌 -要不起显示要不起按钮
        if (lastSeatId != 0)
        {
            //上家是自己（即另外两家不出或者要不起）
            if (lastSeatId == pdk.seatId)
            {
                outCardBtnFather.SetActive(true);
                //outBtn.SetActive(true);
                //tiShiBtn.SetActive(true);
            }
            else
            {
                //判断是否显示要不起
                List<int> myCards = new List<int>();
                for (int i = 0; i < ownCards.Count; i++)
                {
                    if (ownCards[i].gameObject.activeSelf)
                    {
                        myCards.Add((int.Parse)(ownCards[i].spriteName));
                    }
                }
                myCards = SortCardForRule(myCards);
                List<int> tempLastOutCards = new List<int>();
                tempLastOutCards = SortCardForRule(lastOutCards);
                if (PDKCardCompare.isShowOutCardBtn(myCards, tempLastOutCards, lastPokerType))
                {
                    Debug.Log("true lastPokerType" + lastPokerType);
                    Debug.Log("true 显示能出牌");
                    outCardBtnFather.SetActive(true);
                    //outBtn.SetActive(true);
                    //tiShiBtn.SetActive(true);
                }
                else
                {
                    Debug.Log("false lastPokerType" + lastPokerType);
                    Debug.Log("false 显示要不起");
                    //NotOutCardBtn.SetActive(true);
                    //发送要不起出牌消息
                    //List<int> noCards = new List<int>();
                    //SendPDKPlayRequest(POKER_TYPE.Pass, noCards);
                }
            }
        }
        else
        {
            outCardBtnFather.SetActive(false);
            //outBtn.SetActive(false);
            //tiShiBtn.SetActive(false);
            
        }
    }

    /// <summary>
    /// 出牌事件
    /// </summary>
    void OutCardEvent()
    {
        Debug.Log("执行出牌事件");
        //存放选中的牌的列表
        List<int> selectedCards = new List<int>();
        //判断选中的牌 将选中的牌加入列表
        for (int i = 0; i < ownCards.Count;i++ )
        {
            if(ownCards[i].gameObject.activeSelf == true){
                PDKCardButton cardButton = ownCards[i].GetComponent<PDKCardButton>();
                if(cardButton.Select == true){
                    selectedCards.Add(int.Parse(ownCards[i].spriteName));
                }
            }
        }
        //如果存在选中的牌
        if(selectedCards.Count > 0){
            List<int> currentcards = new List<int>();
            //将要出的牌从小到大排序
            currentcards = SortCardForRule(selectedCards);

            POKER_TYPE currentType = POKER_TYPE.Pass;
            //判断牌型 以及选中的牌型是否符合规则
            bool isRule = PDKCardRule.PopEnable(currentcards, out currentType);
            //如果不是自己先出牌 并且游戏没有结束
            if (lastSeatId != pdk.seatId && lastSeatId != 0)
            {
                Debug.Log("不是自己首先出牌");
                if(!isRule){
                    user.logMsg = "你选择牌的牌型不正确，请重新选择3";
                    LogMsg();
                }
                else
                {
                    List<int> tempLastOutCards = new List<int>();
                    //将上家出的牌由小到大排序
                    tempLastOutCards = SortCardForRule(lastOutCards);
                    //若可以出牌
                    if (PDKCardCompare.isSelectCardCanPut(currentcards, currentType, tempLastOutCards, lastPokerType))
                    {
                        SendPDKPlayRequest(currentType, selectedCards);
                        //隐藏button
                        outCardBtnFather.SetActive(false);
                        //outBtn.SetActive(false);
                        //tiShiBtn.SetActive(false); 
                       
                    }
                    else
                    {
                        user.logMsg = "你选择牌的牌不能压住上家，请重新选择";
                        LogMsg();
                    }
                }
            }
            else {           
                //判断是否是牌型 直接发送牌型 和选中的牌
                if (isRule)
                {
                    Debug.Log("自己首先出牌");
                    SendPDKPlayRequest(currentType, selectedCards);
                    //隐藏button
                    outCardBtnFather.SetActive(false);
                    //outBtn.SetActive(false);
                    //tiShiBtn.SetActive(false);
                }
                else
                {
                    //提示牌型不对
                    user.logMsg = "你选择牌的牌型不正确，请重新选择1";
                    LogMsg();

                }
            }
        }
        else
        {
            user.logMsg = "请选择牌";
            LogMsg();
        }
        outBtn.GetComponent<UIButton>().enabled = true;
    }

    /// <summary>
    /// 加载提示框
    /// </summary>
    void LogMsg()
    {
        GameObject logMsg = NGUITools.AddChild(GameObject.Find("UI Root"), (GameObject)(Resources.Load("LogMsg")));
    }


    #region 提示出牌
    int PromptCount = 0;
    Dictionary<int, List<int>> promptCards = new Dictionary<int, List<int>>();
    /// <summary>
    /// 提示出牌
    /// </summary>
    void PromptEvent()
    {
        Debug.Log("上一家的出牌类型：" + lastPokerType);
        if (promptCards.Count == 0)
        {
            List<int> myCards = new List<int>();
            for (int i = 0; i < ownCards.Count; i++)
            {
                if (ownCards[i].gameObject.activeSelf)
                {
                    myCards.Add((int.Parse)(ownCards[i].spriteName));
                }
            }
            myCards = SortCardForRule(myCards);
            List<int> tempLastOutCards = new List<int>();
            if (lastSeatId == pdk.seatId || lastSeatId == 0)
            {
                Debug.Log("第一次出牌");
                promptCards = PDKCardCompare.FindPromptCards(myCards, tempLastOutCards, POKER_TYPE.Pass);
            }
            else
            {
                tempLastOutCards = SortCardForRule(lastOutCards);
                promptCards = PDKCardCompare.FindPromptCards(myCards, tempLastOutCards, lastPokerType);
            }

        }

        for (int i = 0; i < ownCards.Count; i++)
        {
            ownCards[i].gameObject.GetComponent<PDKCardButton>().Select = false;
            ownCards[i].gameObject.transform.localPosition = new Vector3(ownCards[i].gameObject.transform.localPosition.x, 0, 0);
        }
        /*查找牌值 显示到上*/
        for (int i = 0; i < promptCards[PromptCount].Count; i++)
        {
            for (int j = 0; j < ownCards.Count; j++)
            {
                if (ownCards[j].gameObject.activeSelf && ownCards[j].gameObject.GetComponent<PDKCardButton>().Select == false)
                {
                    int tempInt = int.Parse(ownCards[j].spriteName);
                    if (tempInt % 13 == promptCards[PromptCount][i]
                        && tempInt % 13 != 0 )
                    {
                        ownCards[j].gameObject.GetComponent<PDKCardButton>().PromptInit();
                        Debug.Log("提示" + PromptCount + "次");
                        break;
                    }
                    else if (tempInt % 13 == 0 && promptCards[PromptCount][i] == 13)
                    {
                        ownCards[j].gameObject.GetComponent<PDKCardButton>().PromptInit();
                        Debug.Log("提示" + PromptCount + "次");
                        break;
                    }                   
                }
            }
        }
        Debug.Log(PromptCount + "次" + "---总次数" + promptCards.Count);
        PromptCount++;
        if (PromptCount == promptCards.Count)
        {
            PromptCount = 0;
        }
    }
    #endregion 提示出牌


    #region 显示玩家的出牌
    /// <summary>
    /// 显示玩家的出牌
    /// </summary>
    public void ShowPlayerOutCard(List<int> cards, int tempSeatId, POKER_TYPE pokerType, int nextSid)
    {
        //当前出牌的显示
        int tempIndex = pdk.returnOtherSeatIndex(tempSeatId);
        PlayerOutCardFather.SetActive(true);
        Debug.Log("出牌显示：" + pokerType);
        if (pokerType == POKER_TYPE.Pass)
        {
            //显示要不起
            //passStatusObjs[tempIndex].SetActive(true);
            StartCoroutine(HidePassStatus(tempIndex));
        }
        else
        {
            SoundModel.PlayEffectBg(pdkGame.effectBg[0]);
            //有出牌的话 再隐藏上一家出的牌
            for (int i = 0; i < 16; i++)
            {
                pdkPlayerOutCards.playerOutCards[i].gameObject.SetActive(false);              
            }
            //排序
            cards = SortCardForShowUI(cards);  //从小到大排
            if (pokerType == POKER_TYPE.TripleWithSingle || pokerType == POKER_TYPE.TripleWithTwin ||
               pokerType == POKER_TYPE.FourWithSingle || pokerType == POKER_TYPE.FourWithTwin ||
              pokerType == POKER_TYPE.PlaneWithSingle || pokerType == POKER_TYPE.PlaneWithTwin)
            {
                //先排四张 再三张 再两张
                cards = SortCardForShowUIFourOrThreeSame(cards);
            }

            // 出的牌的位置需要进行位移判断
            //if (tempIndex == 0)
            {
                float x = 0 - cards.Count * 15;
                PlayerOutCardFather.transform.localPosition = new Vector3(x, 46, 0);
                //赋值
                for (int i = 0; i < cards.Count; i++)
                {
                    pdkPlayerOutCards.playerOutCards[i].gameObject.SetActive(true);
                    pdkPlayerOutCards.playerOutCards[i].spriteName = cards[i].ToString();
                }
            }
            //计算牌型显示的位置
            //if (!(pokerType == POKER_TYPE.PlanePure || pokerType == POKER_TYPE.PlaneWithSingle || pokerType == POKER_TYPE.PlaneWithTwin))
            {
                int index = cards.Count / 2;
                if(cards.Count > 4){
                    index = cards.Count / 2 - 1;
                }
                Debug.Log("cards.Count = " + cards.Count + "  index = " + index);
                OutCardType.transform.localPosition = new Vector3(pdkPlayerOutCards.playerOutCards[index].transform.localPosition.x,125,0);
            }
            
            
            //显示牌型
            ShowCardType(pokerType);           
        }

        //下一个出牌玩家隐藏出牌状态
        if(nextSid != 0){
            int tempIndex1 = pdk.returnOtherSeatIndex(nextSid);
            if (passStatusObjs[tempIndex1].activeSelf)
            {
                passStatusObjs[tempIndex1].SetActive(false);
                //PlayerOutCardFather.SetActive(false);
            }     
        }
        
    }
    #endregion

    //发送服务器消息
    void SendPDKPlayRequest(POKER_TYPE pdkPokerType, List<int> selectCards)
    {
        RunPlayRequest lg = new Pb.RunPlayRequest();
        //lg.PokerType = pdkPokerType;
        if (selectCards.Count == 0)
        {

        }
        else
        {
            for (int i = 0; i < selectCards.Count; i++)
            {
                lg.CardList.Add(selectCards[i]);
            }
        }
        SocketManager socketManager = SocketManager.Instance;
        socketManager.SendProtobuf1(lg, MsgId.RunPlayRequest);
        Debug.Log("发送出牌请求");
    }


    #region 算法使用排序 从小到大排序 出去去的牌的UI显示排序除了三带 和四带都能用
    /// <summary>
    /// 为算法使用排序  直接从小到大排序
    /// </summary>
    /// <param name="ownCards"></param>
    /// <returns></returns>
    List<int> SortCardForRule(List<int> cards)
    {
        List<int> temp = new List<int>();
        if (cards.Count > 0)
        {
            //先将牌3 - A 从小到大排序
            for (int i = 1; i < 13; i++)
            {
                for (int j = 0; j < cards.Count; j++)
                {                                     
                        int tempInt = cards[j] % 13;
                        if (tempInt == i)
                        {
                            temp.Add(tempInt);
                        }                    
                }
            }
            //若有2 将2添加进列表
            for (int j = 0; j < cards.Count; j++)
            {
                int tempInt = cards[j] % 13;
                if (tempInt == 0)
                {
                    temp.Add(13);
                }
            }        
        }
        return temp;
    }
    #endregion


    #region 从小到大排序 出去去的牌的UI显示排序除了三带 和四带都能用
    /// <summary>
    /// 为算法使用排序  直接从小到大排序
    /// </summary>
    /// <param name="ownCards"></param>
    /// <returns></returns>
    List<int> SortCardForShowUI(List<int> cards)
    {
        List<int> temp = new List<int>();
        if (cards.Count > 0)
        {
            for (int i = 1; i < 13; i++)
            {
                for (int j = 0; j < cards.Count; j++)
                {                    
                        int tempInt = cards[j] % 13;
                        if (tempInt == i)
                        {
                            temp.Add(cards[j]);
                        }                    
                }
            }
            for (int j = 0; j < cards.Count; j++)
            {
                int tempInt = cards[j] % 13;
                if (tempInt == 0)
                {
                    temp.Add(cards[j]);
                }
            }            
        }

        return temp;
    }
    #endregion


    #region ui排序  出去去的牌的UI显示排序三带 和四带能用
    /// <summary>
    /// 为ui使用排序  
    /// </summary>
    /// <param name="ownCards"></param>
    /// <returns></returns>
    List<int> SortCardForShowUIFourOrThreeSame(List<int> cards)
    {
        List<int> temp = new List<int>();
        List<int> tempFourList = new List<int>();
        List<int> tempThreeList = new List<int>();
        List<int> tempTwoList = new List<int>();
        List<int> tempOneList = new List<int>();       
                
        for (int i = 0; i < cards.Count; i++)
        {
            int tempInt = 0;
            for (int j = 0; j < cards.Count; j++)
            {

                if (cards[i] % 13 == cards[j] % 13)
                {
                    tempInt++;
                }

            }
            if (tempInt == 4)
            {
                tempFourList.Add(cards[i]);
            }
            if (tempInt == 3)
            {
                tempThreeList.Add(cards[i]);
            }
            else if (tempInt == 2)
            {
                tempTwoList.Add(cards[i]);
            }
            else if (tempInt == 1)
            {
                tempOneList.Add(cards[i]);
            }

        }
        if (tempFourList.Count > 0)
        {
            for (int i = 0; i < tempFourList.Count; i++)
            {
                temp.Add(tempFourList[i]);
            }
        }
        if (tempThreeList.Count > 0)
        {
            for (int i = 0; i < tempThreeList.Count; i++)
            {
                temp.Add(tempThreeList[i]);
            }
        }
        if (tempTwoList.Count > 0)
        {
            for (int i = 0; i < tempTwoList.Count; i++)
            {
                temp.Add(tempTwoList[i]);
            }
        }
        if (tempOneList.Count > 0)
        {
            for (int i = 0; i < tempOneList.Count; i++)
            {
                temp.Add(tempOneList[i]);
            }
        }
       
        return temp;
    }
    #endregion

    /// <summary>
    /// 隐藏要不起图标
    /// </summary>
    /// <returns></returns>
    IEnumerator HidePassStatus(int index)
    {
        passStatusObjs[index].SetActive(true);
        yield return new WaitForSeconds(1f);
        passStatusObjs[index].SetActive(false);
    }

    /// <summary>
    /// 显示牌型
    /// </summary>
    void ShowCardType(POKER_TYPE pokerType)
    {
        
        if(pokerType == POKER_TYPE.FourBomb){
            //炸弹
            //OutCardType.spriteName = "boom-1";
            OutCardType.gameObject.SetActive(true);
            StartCoroutine(DoAnimation());
        }
        else if (pokerType == POKER_TYPE.FourWithSingle || pokerType == POKER_TYPE.FourWithTwin)
        {
            //四带二
            OutCardType.gameObject.SetActive(true);
            OutCardType.spriteName = "sidaier";           
        }
        else if(pokerType == POKER_TYPE.StraightSingle){
            //顺子
            OutCardType.gameObject.SetActive(true);
            OutCardType.spriteName = "shunzi";
        }
        else if (pokerType == POKER_TYPE.TripleWithSingle || pokerType == POKER_TYPE.TripleWithTwin)
        {
            //三带一
            OutCardType.gameObject.SetActive(true);
            OutCardType.spriteName = "sandaiyi";
        }
        else if (pokerType == POKER_TYPE.StraightTwin)
        {
            //连对
            OutCardType.gameObject.SetActive(true);
            OutCardType.spriteName = "liandui";
        }
        else if (pokerType == POKER_TYPE.PlanePure || pokerType == POKER_TYPE.PlaneWithSingle || pokerType == POKER_TYPE.PlaneWithTwin)
        {
            //飞机
            OutCardType.gameObject.SetActive(true);
            OutCardType.spriteName = "feiji";
        }
        //OutCardType.MakePixelPerfect();
        OutCardType.width = OutCardType.GetAtlasSprite().width;
        OutCardType.height = OutCardType.GetAtlasSprite().height;
        StartCoroutine(HideCardType());
    }

    IEnumerator DoAnimation()
    {
        for (int i = 1; i <= 10; i++)
        {
            OutCardType.spriteName = "boom-" + i.ToString();
            OutCardType.width = OutCardType.GetAtlasSprite().width;
            OutCardType.height = OutCardType.GetAtlasSprite().height;
            yield return new WaitForSeconds(0.1f);


        }
        OutCardType.gameObject.SetActive(false);
    }

    IEnumerator HideCardType()
    {
        yield return new WaitForSeconds(2f);
        OutCardType.gameObject.SetActive(false);
    }
}
